home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-05-21 | 1.7 KB | 66 lines | [TEXT/ttxt] |
- -- Filename:
- -- fish.sx
-
- -- Other Files Required:
- -- This file is loaded by loadme.sx in the animate folder. It requires the MediaImporter
- -- class, defined in mediaimp.sx, and the Animation class, defined in animate.sx.
-
- -- Purpose:
- -- Define a Fish class, which is animated fish which may be dragged and moved
- -- in a space.
-
- -- Specialized Classes:
- -- Fish
-
- -- Instructions to User:
- -- fish.sx imports the media for a Fish animation, and defines a class Fish, a
- -- subclass of Animation, Projectile and Dragger. The init method of Fish sets
- -- up the animation using an array of bitmaps. The Fish class also overrides the
- -- prepareDrag and drop methods, so that another object (the Fish's authorData)
- -- can be informed when the Fish is grabbed and dropped.
-
- -- Author:
- -- Steve Mayer
-
- in module InternetFish
-
- global p := spawn theScriptDir #("media")
- global mm := new MediaImporter path:p smartExtensions:true
- mm.invisibleColor := whiteColor
- mm.convertToShapes := false
-
- -- Import bitmaps for Fish.
- global fishBitmaps := new Array
- for i := 1 to 7 do
- (
- -- Build filename and import bitmap.
- local fileName := ("fishlft" + (i as String) + ".bmp") as StringConstant
- local bm := importObject mm fileName
- append fishBitmaps bm
- )
-
- class Fish (Animation, Projectile, Dragger)
- instance variables
- authorData
- end
-
- method init self {class Fish} #rest args #key authorData: ->
- (
- apply nextMethod self series:fishBitmaps args
- self.authorData := authorData
- self.velocity := new Point x:-6 y:0
- return self
- )
-
- -- Override prepareDrag to inform my container.
- method prepareDrag self {class Fish} location ->
- (
- prepareDrag self.authorData self
- )
-
- -- Override prepareDrag to inform my container.
- method drop self {class Fish} location ->
- (
- drop self.authorData self
- )
-